package com.wyl.clinic.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.common.collect.Lists;
import com.wyl.clinic.entity.Patient;
import com.wyl.clinic.mapper.PatientMapper;
import com.wyl.clinic.service.PatientService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 病人表 服务实现类
 * </p>
 *
 * @author wangyulong
 * @since 2024-02-20
 */
@Service
public class PatientServiceImpl extends ServiceImpl<PatientMapper, Patient> implements PatientService {

    @Override
    public List<Patient> listByUserIds(List<Integer> userIds) {
        if (ObjectUtil.isEmpty(userIds)) return Lists.newArrayList();
        LambdaQueryWrapper<Patient> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(Patient::getUserId, userIds);
        return this.baseMapper.selectList(wrapper);
    }

    @Override
    public Patient getByUserId(Integer userId) {
        LambdaQueryWrapper<Patient> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(Patient::getUserId, userId);
        return this.baseMapper.selectOne(wrapper);
    }
}
